package com.ym.pms.controller;

import com.alibaba.fastjson.JSON;
import com.ym.pms.utils.HttpClientUtil;
import com.ym.pms.utils.JSONResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author: xybh
 * @Description:
 * @Date: Created in 19:36 2020/12/27
 * @Modified:
 */
@Api(tags = "登录接口")
@RestController
@RequestMapping("/login")
public class LoginController {
    @PostMapping("/")
    public JSONResult login(@RequestParam String username,
                            @RequestParam String password){
        HashMap<String, String> params = new HashMap<>();
        params.put("username", username);
        params.put("password", password);
        String res = HttpClientUtil.doPost("http://localhost:8080/login/submit", params);
        return JSON.parseObject(res, JSONResult.class);
    }
}
